package common.main.tianYanCha;

import common.system.FileOperation;

public class TianYanChaConfig {

    public static String mysqlHost = "localhost:3306";  //
    public static String mysqlDatabaseName = "junkewei";   //
    public static String mysqlUserName = "root";           //
    public static String mysqlPassword = "123456";     //
    public static String entranceUrl = null;//"https://www.tianyancha.com/brandsearch/%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD?pn=1";


    public static void init() {
        String content = FileOperation.read("config/tianYanChaConfig.txt");
        String[] lines = content.split("\n");

        for (String line : lines) {
            if (!line.startsWith("#")) {
                line = line.trim();
                if (line.startsWith("mysqlHost")) {
                    mysqlHost = line.split("=")[1].trim();
                } else if (line.startsWith("mysqlDatabaseName")) {
                    mysqlDatabaseName = line.split("=")[1].trim();
                } else if (line.startsWith("mysqlUserName")) {
                    mysqlUserName = line.split("=")[1].trim();
                } else if (line.startsWith("mysqlPassword")) {
                    mysqlPassword = line.split("=")[1].trim();
                } else if (line.startsWith("entranceUrl")) {
                    entranceUrl = line.split("entranceUrl=")[1].trim();
                }
            }
        }
    }
}
